home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 July / CHIP 2006-07.2.iso / program / web_gelistirme / easyphp1-7_setup.exe / {app} / phpmyadmin / libraries / ob.lib.php < prev    next >
Encoding:
PHP Script  |  2003-09-07  |  4.1 KB  |  137 lines

  1. <?php
  2. /* $Id: ob.lib.php,v 1.6 2002/12/06 19:06:04 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5.  
  6. if (!defined('PMA_OB_LIB_INCLUDED')) {
  7.     define('PMA_OB_LIB_INCLUDED', 1);
  8.  
  9.     # Output buffer functions for phpMyAdmin
  10.     #
  11.     # Copyright 2001 Jeremy Brand <jeremy@nirvani.net>
  12.     # http://www.jeremybrand.com/Jeremy/Brand/Jeremy_Brand.html
  13.     #
  14.     # Check for all the needed functions for output buffering
  15.     # Make some wrappers for the top and bottoms of our files.
  16.  
  17.     /**
  18.      * This function be used eventually to support more modes.  It is needed
  19.      * because both header and footer functions must know what each other is
  20.      * doing.
  21.      *
  22.      * @return  integer  the output buffer mode
  23.      */
  24.     function PMA_outBufferModeGet()
  25.     {
  26.         if (PMA_PHP_INT_VERSION >= 40000 && @function_exists('ob_start')) {
  27.             $mode = 1;
  28.         } else {
  29.             $mode = 0;
  30.         }
  31.  
  32.         // If a user sets the output_handler in php.ini to ob_gzhandler, then
  33.         // any right frame file in phpMyAdmin will not be handled properly by
  34.         // the browser. My fix was to check the ini file within the
  35.         // PMA_outBufferModeGet() function.
  36.         //
  37.         // (Patch by Garth Gillespie, modified by Marc Delisle)
  38.         if (PMA_PHP_INT_VERSION >= 40000 && @ini_get('output_handler')) {
  39.             if (@ini_get('output_handler') == 'ob_gzhandler') {
  40.                 $mode = 0;
  41.             }
  42.         } else if (PMA_PHP_INT_VERSION >= 40000) {
  43.             if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
  44.                 $mode = 0;
  45.             }
  46.         }
  47.         // End patch
  48.  
  49.         // If output buffering is enabled in php.ini it's not possible to
  50.         // add the ob_gzhandler without a warning message from php 4.3.0. 
  51.         // Being better safe than sorry, check for any existing output handler
  52.         // instead of just checking the 'output_buffering' setting.
  53.         //
  54.         if (PMA_PHP_INT_VERSION >= 40300 && @function_exists('ob_get_level')) {
  55.             if (ob_get_level() > 0) {
  56.                 $mode = 0;
  57.             }
  58.         }
  59.  
  60.         // Zero (0) is no mode or in other words output buffering is OFF.
  61.         // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
  62.         // Usefull if we ever decide to combine modes.  Then a bitmask field of
  63.         // the sum of all modes will be the natural choice.
  64.  
  65.         header('X-ob_mode: ' . $mode);
  66.  
  67.         return $mode;
  68.     } // end of the 'PMA_outBufferModeGet()' function
  69.  
  70.  
  71.     /**
  72.      * This function will need to run at the top of all pages if output
  73.      * output buffering is turned on.  It also needs to be passed $mode from
  74.      * the PMA_outBufferModeGet() function or it will be useless.
  75.      *
  76.      * @param   integer  the output buffer mode
  77.      *
  78.      * @return  boolean  whether output buffering is enabled or not
  79.      */
  80.     function PMA_outBufferPre($mode)
  81.     {
  82.         switch($mode)
  83.         {
  84.             case 1:
  85.                 ob_start('ob_gzhandler');
  86.                 $retval = TRUE;
  87.                 break;
  88.  
  89.             case 0:
  90.                 $retval = FALSE;
  91.                 break;
  92.  
  93.             // loic1: php3 fix
  94.             default:
  95.                 $retval = FALSE;
  96.                 break;
  97.         } // end switch
  98.  
  99.         return $retval;
  100.     } // end of the 'PMA_outBufferPre()' function
  101.  
  102.  
  103.     /**
  104.      * This function will need to run at the bottom of all pages if output
  105.      * buffering is turned on.  It also needs to be passed $mode from the
  106.      * PMA_outBufferModeGet() function or it will be useless.
  107.      *
  108.      * @param   integer  the output buffer mode
  109.      *
  110.      * @return  boolean  whether data has been send from the buffer or not
  111.      */
  112.     function PMA_outBufferPost($mode)
  113.     {
  114.         switch($mode)
  115.         {
  116.             case 1:
  117.                 # This output buffer doesn't need a footer.
  118.                 $retval = TRUE;
  119.                 break;
  120.  
  121.             case 0:
  122.                 $retval = FALSE;
  123.                 break;
  124.  
  125.             // loic1: php3 fix
  126.             default:
  127.                 $retval = FALSE;
  128.                 break;
  129.         } // end switch
  130.  
  131.         return $retval;
  132.     } // end of the 'PMA_outBufferPost()' function
  133.  
  134. } // $__PMA_OB_LIB__
  135.  
  136. ?>
  137.